package com.ihr360.insurance.model.dto.benefits;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ihr360.commons.annotation.CodeGenerator;
import com.ihr360.commons.lang.SystemInfo;
import com.ihr360.commons.model.ITemporalEnabledEntity;
import com.ihr360.commons.model.type.BenefitCategory;
import com.ihr360.shared.entitywithlistener.NumberIdWithTime;
import com.ihr360.shared.sequence.handler.CodeGeneratorHandler;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Transient;
import java.util.Date;

/** 法定福利类型 */
@Entity
@EntityListeners(CodeGeneratorHandler.class)
public class MandatoryBenefitsType extends NumberIdWithTime<Long> implements ITemporalEnabledEntity {

    private static final long serialVersionUID = 8538276373016189323L;

    public static final class Field {
        public final static String name = "name";
    }


    /** 代码 */
    @CodeGenerator(bizModel = "mandatory_benefit_type", length = 5, serialTmpl = "SERIALGEN(category,\"_TYPE_\",MAXID)", name = "社保公积金类型序列号", categoryId = "SERIALID(category)")
    @Column(unique = true, nullable = false, length = 20)
    private String code;

    /** 名称 */
    @Column(nullable = false, length = 200,unique = true)
    private String name;

    /** 生效时间 */
    @Column(nullable = false)
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    private Date effectiveAt;

    /** 失效时间 */
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    private Date invalidAt;

    /** 法定福利分类 */
    @Column(nullable = false, length = 20)
    @Enumerated(EnumType.STRING)
    private BenefitCategory category = BenefitCategory.SI;

    /**
     * 公积金子类型
     */
//    @Column(length = 20)
//    @Enumerated(EnumType.STRING)
//    private HFSubType hfSubType = HFSubType.CUSTOM;

    /** 是否启用 */
    private Boolean enabled = true;

    @Column(length = 1000)
    public String remark;

    @Transient
    private SystemInfo.User creator;

    @Transient
    private SystemInfo.User updater;

    public SystemInfo.User getCreator() {
        return creator;
    }

    public void setCreator(SystemInfo.User creator) {
        this.creator = creator;
    }

    public SystemInfo.User getUpdater() {
        return updater;
    }

    public void setUpdater(SystemInfo.User updater) {
        this.updater = updater;
    }

    public BenefitCategory getCategory() {
        return category;
    }

    public void setCategory(BenefitCategory category) {
        this.category = category;
    }

//    public HFSubType getHfSubType() {
//        return hfSubType;
//    }
//
//    public void setHfSubType(HFSubType hfSubType) {
//        this.hfSubType = hfSubType;
//    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    @Override
    public Date getEffectiveAt() {
        return effectiveAt;
    }
    @Override
    public void setEffectiveAt(Date effectiveAt) {
        this.effectiveAt = effectiveAt;
    }
    @Override
    public Date getInvalidAt() {
        return invalidAt;
    }

    @Override
    public void setInvalidAt(Date invalidAt) {
        this.invalidAt = invalidAt;
    }
    @Override
    public boolean isEnabled() {
        return this.enabled;
    }
    @Override
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
